from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from apps.courses.models import *
from apps.courses.courser_sers import CourseTypeSer, CourseSer


# 渲染数据库课程类型
class CoursesType(APIView):
    def get(self, request):
        courtype = CourseType.objects.all()
        ser = CourseTypeSer(courtype, many=True)
        return Response({'code': 200, 'message': '成功', 'courtype_list': ser.data})


class Courses(APIView):
    """
    获取课程
    """

    def get(self, request):
        course = Course.objects.all()
        ser = CourseSer(course, many=True)
        return Response({'code': 200, 'message': '成功', 'data': ser.data})

# Create your views here.
